{% extends 'master.html' %}
{% block publish_funcs %}{% load publish_funcs %}{% endblock %}
{% block All %}
		<div id="wrapper">
        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <div style="height: 50px;font-size:15px;font-weight:bold;vertical-align:middle;margin-top: 20px;">
                        <form method="post" action="/backend/monitor">
                          {% csrf_token %}
                          <span> &nbsp </span>
                          <span >选择主机：</span>
                          <select name="minion_db_id" style="width:200px;">
                              {% for row in minions_id %}
																	{% ifequal row.minion_id  minion_id  %}
                                  		<option selected = "selected" value="{{ row.minion_id }}">{{ row.minion_id }}</option>
																	{% else %}
																			<option  value="{{ row.minion_id }}">{{ row.minion_id }}</option>
																	{% endifequal %}
                              {% endfor %}
                          </select>

                          <span> &nbsp </span>
                          <span> &nbsp </span>
                          <span>选择查询时间：</span>
                          <span><input name='begintime' type="datetime-local" value="" /> </span>
                          <span> - </span>
                          <span><input name='endtime' type="datetime-local" value="" /></span>
                          <button type="submit" class="btn btn-primary" style="float:right;">查询</button>
													<div class="page-header"></div>
                        </form>

                    </div>
                </div>
                <!--
                <div class="col-lg-12">
                    <div>
                        <div id="test" style="width: 550px;height:300px;"></div>
                    </div>
                </div>
                -->
                <!--CPU-->
							   <div class="col-lg-12">
									 	<div class="titleCss" >&nbsp System And CPU Monitor</div>
                    <p></p>
                    <div>
                        <div id='sysparameters' class="bodyCss"></div>
												<span></span>
                        <div id='cpuload' class="bodyCss"></div>
                    </div>
                 </div>

							   <!--内存-->
							   <div class="col-lg-12">
									 	<div class="titleCss" >&nbsp Memery Monitor</div>
                    <p></p>
                    <div>
                        <span id='memeryUsePercent' class="bodyCss"></span>
												<span></span>
											  <span id='memeryPhysical' class="bodyCss"></span>
												<span></span>
                        <span id='memerySwap' class="bodyCss"></span>
                    </div>
                 </div>

							   <!--DiskIO-->
							   <div class="col-lg-12">
									 	<div class="titleCss" >&nbsp DiskIO Monitor</div>
                    <p></p>
                    <div>
                        <span id='diskio' class="bodyCss"></span>
												<span></span>
											  <span id='seconddiskio' class="bodyCss"></span>
												<span></span>
                    </div>
                 </div>

							   <!--Network IO-->
							   <div class="col-lg-12">
									 	<div class="titleCss" >&nbsp Network Monitor</div>
                    <p></p>
                    <div>
                        <span id='networkio' class="bodyCss"></span>
												<span></span>
											  <span id='secondnetworkio' class="bodyCss"></span>
												<span></span>
                    </div>
                 </div>
							   <!--Netstat-->
							   <div class="col-lg-12">
									 	<div class="titleCss" >&nbsp Tcp Netstat Monitor</div>
                    <p></p>
                    <div>
                        <span id='netstat' class="bodyCss"></span>
												<span></span>
                    </div>
                 </div>






            </div>
        </div>
        <!-- /#page-wrapper -->
    </div>
    <!-- /#wrapper -->
{% endblock %}




{% block username %}{{ username }}{% endblock %}


{% block adminscript %}

<script type="text/javascript">


    function timesplit(arr){
        //传入一个时间数组即可切割
        //var arr = [args];
        var temp = [];
        for(var i = 0; i< arr.length; i++) {
          temp.push(arr[i].split(' ')[1]);
        }
        return temp
    }



//CPU负载出图
echarts.init(document.getElementById('cpuload')).setOption({
    title: { text: 'CPU负载变化图'},
    tooltip: {},
    legend: {
//        'scroll': true,
        data:['当前负载','一分钟负载','\n','五分钟负载','十五分钟负载'],
    } ,
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis: {
//        data: temp,
        showAllSymbol: true,
//        data: [{% for row in cpuload %}'{{ row.create_time }}',{% endfor %}],
        data: timesplit([{% for row in cpuload %}'{{ row.create_time }}',{% endfor %}])
    },
    yAxis: {
       type : 'value',
       axisLabel : {formatter: '{value} %'}
    },
    series: [
            {
                name: '当前负载',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
//                symbol: 'none',  //去圆点
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in cpuload %}{{ row.nowpercent }},{% endfor %}],
            },
			  {
            name: '一分钟负载',
            type: 'line',
            symbolSize: 0.5,  //设置圆点大小
//            symbol: 'none',  //去圆点
            smooth:true,  //折线平滑
            showAllSymbol: true,
            data: [{% for row in cpuload %}{{ row.loadone }},{% endfor %}],
        },
			  {
            name: '五分钟负载',
            type: 'line',
            symbolSize: 0.5,  //设置圆点大小
//            symbol: 'none',  //去圆点
            smooth:true,  //折线平滑
            showAllSymbol: true,
            data: [{% for row in cpuload %}{{ row.loadfive }},{% endfor %}],
        },
        {
            name: '十五分钟负载',
            type: 'line',
            symbolSize: 0.5,
//            symbol: 'none',
            smooth:true,  //折线平滑
            showAllSymbol: true,
            data: [{% for row in cpuload %}{{ row.loadfiften }},{% endfor %}],
        }

    ],
});

//系统项监控出图
echarts.init(document.getElementById('sysparameters')).setOption({
    title: { text: '系统值'},
    tooltip: {},
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            magicType: {show: true, type: ['line', 'bar']},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    legend: {
//        'scroll': true,
        data:['用户数','进程数'],
    } ,
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis: {
//        data: temp,
        showAllSymbol: true,
//        data: [{% for row in cpuload %}'{{ row.create_time }}',{% endfor %}],
        data: timesplit([{% for row in sysparameters %}'{{ row.create_time }}',{% endfor %}])
    },
    yAxis: {
       type : 'value',
       axisLabel : {formatter: '{value} 个'}
    },
    series: [
            {
                name: '用户数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in sysparameters %}{{ row.usercount }},{% endfor %}],
            },
            {
                name: '进程数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in sysparameters %}{{ row.pids }},{% endfor %}],
            }
    ],
});

//内存使用百分比监控出图
echarts.init(document.getElementById('memeryUsePercent')).setOption({
    title: { text: '内存使用百分比', top: 10, left: 10},
    tooltip: {},
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            magicType: {show: true, type: ['line', 'bar']},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    legend: {

        type: 'scroll',
        bottom: 10,
        data:['物理内存使用百分比','Swap内存使用百分比'],
    } ,
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '10%',
        containLabel: true
    },
    xAxis: {
//        data: temp,
        showAllSymbol: true,
//        data: [{% for row in memeryminions %}'{{ row.create_time }}',{% endfor %}],
        data: timesplit([{% for row in memeryminions %}'{{ row.create_time }}',{% endfor %}])
    },
    yAxis: {
       type : 'value',
       axisLabel : {formatter: '{value} %'}
    },
    series: [
            {
                name: '物理内存使用百分比',
                type: 'bar',
                showAllSymbol: true,
                data: [{% for row in memeryminions %}{{ row.percent }},{% endfor %}],
            },
            {
                name: 'Swap内存使用百分比',
                type: 'bar',
                showAllSymbol: true,
                data: [{% for row in memeryminions %}{{ row.swap_percent }},{% endfor %}],
            }
    ],
});

//内存物理监控出图
echarts.init(document.getElementById('memeryPhysical')).setOption({
    title: { text: '物理内存监控', top: 10, left: 10},
    tooltip: {},
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            magicType: {show: true, type: ['line', 'bar']},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    legend: {

        type: 'scroll',
        bottom: 10,
        data:['物理内存总数','剩余内存','使用的内存','未使用的内存','在使用内存','未使用内存','缓存文件系统元数据','缓存各种东西','共享使用的内存'],
    } ,
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '10%',
        containLabel: true
    },
    xAxis: {
//        data: temp,
        showAllSymbol: true,
//        data: [{% for row in memeryminions %}'{{ row.create_time }}',{% endfor %}],
        data: timesplit([{% for row in memeryminions %}'{{ row.create_time }}',{% endfor %}])
    },
    yAxis: {
       type : 'value',
       axisLabel : {formatter: '{value} M'}
    },
    series: [
            {
                name: '物理内存总数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in memeryminions %}{{ row.total }},{% endfor %}],
            },
            {
                name: '剩余内存',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in memeryminions %}{{ row.available }},{% endfor %}],
            },
						{
                name: '使用的内存',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in memeryminions %}{{ row.used }},{% endfor %}],
            },
						{
                name: '未使用的内存',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in memeryminions %}{{ row.free }},{% endfor %}],
            },
						{
                name: '在使用内存',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in memeryminions %}{{ row.active }},{% endfor %}],
            },
						{
                name: '未使用内存',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in memeryminions %}{{ row.inactive }},{% endfor %}],
            },
						{
                name: '缓存文件系统元数据',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in memeryminions %}{{ row.buffers }},{% endfor %}],
            },
						{
                name: '缓存各种东西',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in memeryminions %}{{ row.cached }},{% endfor %}],
            },
						{
                name: '共享使用的内存',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in memeryminions %}{{ row.shared }},{% endfor %}],
            },
    ],
});

//虚拟内存监控出图
echarts.init(document.getElementById('memerySwap')).setOption({
    title: { text: '虚拟内存', top: 10, left: 10},
    tooltip: {},
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            magicType: {show: true, type: ['line', 'bar']},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    legend: {
        type: 'scroll',
        bottom: 10,
        data:['总交换内存','已使用的交换内存','可使用的交换内存','从磁盘交换的内存','从磁盘换出的内存'],
    } ,
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '10%',
        containLabel: true
    },
    xAxis: {
//        data: temp,
        showAllSymbol: true,
//        data: [{% for row in memeryminions %}'{{ row.create_time }}',{% endfor %}],
        data: timesplit([{% for row in memeryminions %}'{{ row.create_time }}',{% endfor %}])
    },
    yAxis: {
       type : 'value',
       axisLabel : {formatter: '{value} M'}
    },
    series: [
            {
                name: '总交换内存',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in memeryminions %}{{ row.swap_total }},{% endfor %}],
            },
            {
                name: '已使用的交换内存',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in memeryminions %}{{ row.swap_used }},{% endfor %}],
            },
            {
                name: '可使用的交换内存',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in memeryminions %}{{ row.swap_free }},{% endfor %}],
            },
						{
                name: '从磁盘交换的内存',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in memeryminions %}{{ row.swap_sin }},{% endfor %}],
            },
						{
                name: '从磁盘换出的内存',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in memeryminions %}{{ row.swap_sout }},{% endfor %}],
            }
    ],
});


//diskio监控出图
echarts.init(document.getElementById('diskio')).setOption({
    title: { text: '总磁盘IO', top: 10, left: 10},
    tooltip: {},
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            magicType: {show: true, type: ['line', 'bar']},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    legend: {
        type: 'scroll',
        bottom: 10,
        data:['总读取次数','总写入次数','总读取字节数','总写入字节数','总内从磁盘读取时间','总内从磁盘写入时间'],
    } ,
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '10%',
        containLabel: true
    },
    xAxis: {
//        data: temp,
        showAllSymbol: true,
//        data: [{% for row in memeryminions %}'{{ row.create_time }}',{% endfor %}],
        data: timesplit([{% for row in diskio %}'{{ row.create_time }}',{% endfor %}])
    },
    yAxis: {
       type : 'value',
       axisLabel : {formatter: '{value} M'}
    },
    series: [
            {
                name: '总读取次数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in diskio %}{{ row.all_read_count }},{% endfor %}],
            },
            {
                name: '总写入次数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in diskio %}{{ row.all_write_count }},{% endfor %}],
            },
            {
                name: '总读取字节数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in diskio %}{{ row.all_read_bytes }},{% endfor %}],
            },
						{
                name: '总写入字节数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in diskio %}{{ row.all_write_bytes }},{% endfor %}],
            },
						{
                name: '总内从磁盘读取时间',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in diskio %}{{ row.all_read_time }},{% endfor %}],
            },
						{
                name: '总内从磁盘写入时间',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in diskio %}{{ row.all_write_time }},{% endfor %}],
            }
    ],
});

//1秒diskio变化监控出图
echarts.init(document.getElementById('seconddiskio')).setOption({
    title: { text: '磁盘每秒IO', top: 10, left: 10},
    tooltip: {},
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            magicType: {show: true, type: ['line', 'bar']},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    legend: {
        type: 'scroll',
        bottom: 10,
        data:['1秒总读取次数','1秒总写入次数','1秒总读取字节数','1秒总写入字节数','1秒总内从磁盘读取时间','1秒总内从磁盘写入时间'],
    } ,
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '10%',
        containLabel: true
    },
    xAxis: {
//        data: temp,
        showAllSymbol: true,
//        data: [{% for row in memeryminions %}'{{ row.create_time }}',{% endfor %}],
        data: timesplit([{% for row in diskio %}'{{ row.create_time }}',{% endfor %}])
    },
    yAxis: {
       type : 'value',
       axisLabel : {formatter: '{value} M'}
    },
    series: [
            {
                name: '1秒总读取次数',
                type: 'bar',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in diskio %}{{ row.read_count }},{% endfor %}],
            },
            {
                name: '1秒总写入次数',
                type: 'bar',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in diskio %}{{ row.write_count }},{% endfor %}],
            },
            {
                name: '1秒总读取字节数',
                type: 'bar',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in diskio %}{{ row.read_bytes }},{% endfor %}],
            },
						{
                name: '1秒总写入字节数',
                type: 'bar',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in diskio %}{{ row.write_bytes }},{% endfor %}],
            },
						{
                name: '1秒总内从磁盘读取时间',
                type: 'bar',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in diskio %}{{ row.read_time }},{% endfor %}],
            },
						{
                name: '1秒总内从磁盘写入时间',
                type: 'bar',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in diskio %}{{ row.write_time }},{% endfor %}],
            }
    ],
});

//network io
echarts.init(document.getElementById('networkio')).setOption({
    title: { text: '网络信息', top: 10, left: 10},
    tooltip: {},
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            magicType: {show: true, type: ['line', 'bar']},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    legend: {
        type: 'scroll',
        bottom: 10,
        data:['发送的字节数','收到的字节数','发送的数据包数量','接收的数据包数量','接收时错误的总数','发送时错误的总数','丢弃的数据包总数','丢弃的发送的包总数'],
    } ,
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '10%',
        containLabel: true
    },
    xAxis: {
//        data: temp,
        showAllSymbol: true,
//        data: [{% for row in networkio %}'{{ row.create_time }}',{% endfor %}],
        data: timesplit([{% for row in networkio %}'{{ row.create_time }}',{% endfor %}])
    },
    yAxis: {
       type : 'value',
       axisLabel : {formatter: '{value} M'}
    },
    series: [
            {
                name: '发送的字节数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in networkio %}{{ row.all_bytes_sent }},{% endfor %}],
            },
            {
                name: '收到的字节数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in networkio %}{{ row.all_bytes_recv }},{% endfor %}],
            },
            {
                name: '发送的数据包数量',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in networkio %}{{ row.all_packets_sent }},{% endfor %}],
            },
						{
                name: '接收的数据包数量',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in networkio %}{{ row.all_packets_recv }},{% endfor %}],
            },
						{
                name: '接收时错误的总数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in networkio %}{{ row.all_errin }},{% endfor %}],
            },
						{
                name: '发送时错误的总数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in networkio %}{{ row.all_errout }},{% endfor %}],
            },
						{
                name: '丢弃的数据包总数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in networkio %}{{ row.all_dropin }},{% endfor %}],
            },
						{
                name: '丢弃的发送的包总数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in networkio %}{{ row.all_dropout }},{% endfor %}],
            },
    ],
});

//1秒network io变化
echarts.init(document.getElementById('secondnetworkio')).setOption({
    title: { text: '网络信息', top: 10, left: 10},
    tooltip: {},
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            magicType: {show: true, type: ['line', 'bar']},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    legend: {
        type: 'scroll',
        bottom: 10,
        data:['1秒发送的字节数','1秒收到的字节数','1秒发送的数据包数量','1秒接收的数据包数量','1秒接收时错误的总数','1秒发送时错误的总数','1秒丢弃的数据包总数','1秒丢弃的发送的包总数'],
    } ,
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '10%',
        containLabel: true
    },
    xAxis: {
//        data: temp,
        showAllSymbol: true,
//        data: [{% for row in networkio %}'{{ row.create_time }}',{% endfor %}],
        data: timesplit([{% for row in networkio %}'{{ row.create_time }}',{% endfor %}])
    },
    yAxis: {
       type : 'value',
       axisLabel : {formatter: '{value} M'}
    },
    series: [
            {
                name: '1秒发送的字节数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in networkio %}{{ row.bytes_sent }},{% endfor %}],
            },
            {
                name: '1秒收到的字节数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in networkio %}{{ row.bytes_recv }},{% endfor %}],
            },
            {
                name: '1秒发送的数据包数量',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in networkio %}{{ row.packets_sent }},{% endfor %}],
            },
						{
                name: '1秒接收的数据包数量',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in networkio %}{{ row.packets_recv }},{% endfor %}],
            },
						{
                name: '1秒接收时错误的总数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in networkio %}{{ row.errin }},{% endfor %}],
            },
						{
                name: '1秒发送时错误的总数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in networkio %}{{ row.errout }},{% endfor %}],
            },
						{
                name: '1秒丢弃的数据包总数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in networkio %}{{ row.dropin }},{% endfor %}],
            },
						{
                name: '1秒丢弃的发送的包总数',
                type: 'line',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in networkio %}{{ row.dropout }},{% endfor %}],
            },
    ],
});

//TCP连接数
echarts.init(document.getElementById('netstat')).setOption({
    title: { text: 'Tcp 连接数', top: 10, left: 10},
    tooltip: {},
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            magicType: {show: true, type: ['line', 'bar']},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    legend: {
        type: 'scroll',
        bottom: 10,
        data:['established','last_ack','time_wait','syn_sent','close_wait','listen'],
    } ,
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '10%',
        containLabel: true
    },
    xAxis: {
//        data: temp,
        showAllSymbol: true,
//        data: [{% for row in netsstat %}'{{ row.create_time }}',{% endfor %}],
        data: timesplit([{% for row in netsstat %}'{{ row.create_time }}',{% endfor %}])
    },
    yAxis: {
       type : 'value',
       axisLabel : {formatter: '{value} 个'}
    },
    series: [
            {
                name: 'established',
                type: 'bar',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in netsstat %}{{ row.established }},{% endfor %}],
            },
            {
                name: 'last_ack',
                type: 'bar',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in netsstat %}{{ row.last_ack }},{% endfor %}],
            },
            {
                name: 'time_wait',
                type: 'bar',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in netsstat %}{{ row.time_wait }},{% endfor %}],
            },
						{
                name: 'syn_sent',
                type: 'bar',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in netsstat %}{{ row.syn_sent }},{% endfor %}],
            },
						{
                name: 'close_wait',
                type: 'bar',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in netsstat %}{{ row.close_wait }},{% endfor %}],
            },
						{
                name: 'listen',
                type: 'bar',
                symbolSize: 0.5,  //设置圆点大小
                smooth:true,  //折线平滑
                showAllSymbol: true,
                data: [{% for row in netsstat %}{{ row.listen }},{% endfor %}],
            }
    ],
});


</script>
{% endblock %}
